package com.xbts.screen.controller.video;

import com.xbts.common.core.web.controller.BaseController;
import com.xbts.common.core.web.domain.AjaxResult;
import com.xbts.common.core.web.page.PageDomain;
import com.xbts.common.core.web.page.TableSupport;
import com.xbts.common.security.annotation.RequiresPermissions;
import com.xbts.screen.service.impl.VideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * @author : llk
 * @Date: 2023/12/25 15:32
 */
@RequestMapping("/video")
@RestController
@Api(tags = "视频管理")
public class VideoController extends BaseController {

    @Resource
    private VideoService videoService;

    /**
     * 获取在线设备通道列表
     */
    @ApiOperation("获取在线设备通道列表")
    @RequiresPermissions("screen:video:list")
    @GetMapping("/deviceChannelPage")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "unitTypeList", value = "单元类型列表", required = true, dataType = "List", paramType = "path"),
            @ApiImplicitParam(name = "channelTypeList", value = "通道类型列表", required = true, dataType = "List", paramType = "path"),
            @ApiImplicitParam(name = "isOnline", value = "是否在线", required = true, dataType = "Integer", paramType = "path")
    })
    public AjaxResult getDeviceChannelPage(@RequestParam List<String> unitTypeList, @RequestParam List<String> channelTypeList, @RequestParam Integer isOnline) {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        if (unitTypeList.isEmpty()) {
            unitTypeList = Collections.singletonList("1");
        }
        if (channelTypeList.isEmpty()) {
            channelTypeList = Collections.singletonList("1");
        }
        if (isOnline == null) {
            isOnline = 1;
        }
        return success(videoService.getDeviceChannelPage(pageDomain.getPageNum(), pageDomain.getPageSize(),
                unitTypeList, channelTypeList, isOnline));
    }
}